<div class="list-toolbar">
	{%if CreateLink%}
	<a class="button create-link" href="{% CreateLink %}"><button type="button" title="{% i < `Create` %}"></button></a>
	{%endif%}
	{%if PageSize%}
	<fieldset class="nav-group">
		{%ifnot FirstPage%}
			<a class="button prev-page-link" href="{% PrevPageLink %}"><button type="button" title="{% i <  `Previous page` %}"></button>
		{%endif%}
			<span id="lb" class="range-bound">{% LowBound %}</span>
		{%ifnot FirstPage%}
			</a>
			<div id="lb_ranges" class="range-menu" style="display:none;position:absolute;z-index:100;">
			{%iterate PreviousRanges as r%}
				<a href="{% Url %}">{% LowBound %}-{% HighBound %}</a>
			{%iterate%}
			</div>
		{%endif%}	
			-
		{%ifnot LastPage%}
			<a class="button next-page-link" href="{% NextPageLink %}">
		{%endif%}
			<span id="hb" class="range-bound">{% HighBound %}</span>
		{%ifnot LastPage%}	
			<button type="button" title="{% i <  `Next page` %}"></button>
			</a>
			<div id="hb_ranges" class="range-menu" style="display:none;position:absolute;z-index:100;">
				{%iterate NextRanges as r%}
					<a href="{% Url %}">{% LowBound %}-{% HighBound %}</a>
				{%iterate%}
			</div>
		{%endif%}		
	</fieldset>
	{%endif%}
	<fieldset>
	<form class="toolbar" method="post">
		<input type="hidden" name="method" value="SetSearchValue" />
		<input type="text" name="criteria" value="{% q < SearchValue %}" />
		<button type="button" onclick="javascript:submit();">{% i < `Search` %}</button>
	</form>
	</fieldset>
	<fieldset>
	<button type="button" class="popup">Колонки</button>
	<div class="popup">
	<form class="toolbar" method="post">
		<input type="hidden" name="method" value="SetDisplayProperties" />
		{%iterate AvailableColumns as col%}
		<div><input name="display[{% Name %}]" type="checkbox"{%if IsShown%} checked{%endif%} />{% i < context %}</div>
		{%iterate%}
		<button type="button" onclick="javascript:submit();">{% i < `Apply` %}</button>
	</form>
	</div>
	</fieldset>
</div>
<script language="javascript">
	$(document).one("ready",function(){
		$("div.popup").mousemove(function(){return false;}).each(
				function(i){
					var offset = $(this).prev().offset();
					$(this).css('left',offset.left).css('top',offset.top + $(this).prev().height());
				}
			);
		$("button.popup").click(function(){
			$(this).next().toggle();
			if ($(this).next().css('display') != 'none')
				$(document).one('mousemove',function(){$("div.popup").hide();});
		}).mousemove(function(){return false;});
		
		$("span.range-bound").mouseenter(function(e){
			var offset = $(this).position(); 
			$('#'+this.id+'_ranges').css("left",offset.left).css("top",offset.top+$(this).outerHeight()).show('fast');
			$(document.body).one("mousemove",function(e){$("div.range-menu").hide("fast");});
		}).mousemove(function(){return false;});
		$('div.range-menu').mousemove(function(){return false});
	});
</script>
<table class="items-list">
	<tr>
	{%assign _dp_ DisplayProperties %}
		{%iterate _dp_ as property%}
			<th>
				<table>
					<tr>
					<td>
				{%ifnot Type TItemPropertyType::PT_COLLECTION %}
					<a class="sort-link" href="{% SortingUrl < Name %}">
				{%endif%}
				{%ifnot Type TItemPropertyType::PT_BOOL %}
					{% i <  Caption %}
				{%else%}
					<img src="{% $THEME_URL %}/img/Yes.png" title="{% i < Caption %}" />
				{%endif%}
				{%ifnot Type TItemPropertyType::PT_COLLECTION %}
					{%if Name SortingProperty%}
						</td>
						<td>
						<img src="{% $THEME_URL %}/img/{%switch SortingOrder%}{%case TSortingType::SORT_DESC%}Up16.png{%endcase%}{%case TSortingType::SORT_ASC%}Down16.png{%endcase%}{%endswitch%}" />
					{%endif%}
					</a>
				{%endif%}
				</td>
				</tr>
				</table>
			</th>
		{%iterate%}
		<th></th>
	</tr>
	{%iterate List as item%}
	{%assign _container_ context%}
	<tr class="list-item{%odd%} odd{%endodd%}">
		{%iterate _dp_ as property%}
		<?php $this->_global_vars_['_p_'] = $this->_global_vars_['_container_']->Property($this->CurrentContext()->Name()); ?>
		{%with _p_%}
		<td>
			{%switch Type%}
				{%case TItemPropertyType::PT_FILE%}
					{%with Value%}
					<a href="{% GetLink %}">{% Name %}</a>
					{%endwidth%}
				{%endcase%}
				{%case TItemPropertyType::PT_IMAGE%}
					{%with Value%}
					<a class="imageloader" href="{% GetLink %}"><img src="{% q <  GetThumbnailLink %}" height="40" /></a>
					{%endwith%}
				{%endcase%}
				{%case TItemPropertyType::PT_DATE%}
					{%if Value%}{% d < Value %}{%endif%}
				{%endcase%}
				{%case TItemPropertyType::PT_BOOL%}
					<div class="bool-value {%if Value%}bool-yes{%else%}bool-no{%endif%}"><input type="checkbox"{%if Value%} checked{%endif%} onclick="return false;"/></div>
				{%endcase%}
				{%case TItemPropertyType::PT_SET%}
					{%iterate Value as element%}
					<div class="set-value">{% i <  element %}</div>
					{%iterate%}
				{%endcase%}
				{%case TItemPropertyType::PT_COLLECTION%}
					{%iterate Value as element%}
						{%insert collectionitem.tpl%}
					{%iterate%}
				{%endcase%}
				{%case TItemPropertyType::PT_REFERENCE%}
					{%if Value%}
						{%assign url ItemNavigationUrl < ReferedInstance %}
						{%if url %}<a href="{% q < url %}">{%endif%}{% ReferedInstance %}{%if url %}</a>{%endif%}
					{%endif%}
				{%endcase%}
				{%default%}
					{%if Selection%}
						{% i < DisplayValue %}
					{%else%}
						{% Value %}
					{%endif%}
				{%endcase%}
			{%endswitch%}
		</td>
		{%endwith%}
		{%iterate%}
		<td class="actions-container">
			{%iterate ActionUrls as act > url %}
			<a class="button {% act %}-link" href="{% q < url %}"><button type="button" title="{% i < act %}"></button></a>
			{%iterate%}
		</td>
	</tr>
	{%iterate%}
</table>
